package com.mycompany;
import java.util.ArrayList;
import java.util.Arrays;

import com.hostmann.corejava.*;

public class EmployeeTest {
    
//    public static void aTest (double [] d) {
//        for (double dn :d ) {
//            System.out.println(dn);
//        }
//    }
    public static void aTest (double... d) {
        for (double dn :d ) {
            System.out.println(dn);
        }
    }
    /**
     * @see com.hostmann.corejava.Employee#raiseSalary(double)
     * @param args
     */
    public static void main (String [] args) {
//        Employee [] staff = new Employee[3];
////        staff[0] = new Employee("Amy Zou", 75000, 1987, 12, 15);
////        staff[1] = new Employee("Kevin Chou", 50000, 1989, 10, 1);
////        staff[2] = new Employee("Tony Chen", 40000, 1990, 3, 1);
        ArrayList <Employee> staff = new ArrayList<Employee>();
        Manager boss = new Manager("Amy Zou", 100000, 20000);
        staff.add(boss);
        staff.add(new Employee("Kevin Chou", 50000));
        staff.add(new Employee(60000));
        
        for (Employee e : staff){
            e.raiseSalary(5);
//            e.setId();
        }
        
        for (Employee e : staff){
            System.out.printf("Name: %-10s, Salary: %.2f, ID: %-4d, Data: %s\n", e.getName(), e.getSalary(), e.getId(), e.getHireDay().toString());
//            System.out.printf("Name: %11s, Salary: %.2f\n", e.getName(), e.getSalary());
        }
        int nextid = Employee.getNextId();
        System.out.printf("next id is %d\n", nextid);
        
        Person [] people = new Person[2];
        people[0] = new Student("Tumi", "Computer");
        people[1] = new Manager("Amy", 90000, 5000);
        
        for (Person p: people) {
            System.out.println(p.getDescription());
        }
        System.out.println(people[1].toString());
        System.out.println(people[1].hashCode());
        
        System.out.println(staff.get(1));
        staff.remove(1);
        System.out.println(staff.get(1));
        
        double [] d1 = new double [3];
        d1 [0] = 1;
        d1 [1] = 2;
        d1 [2] = 3;
        
        double [] d2 = new double [3];
        d2 [0] = 4;
        d2 [1] = 5;
        d2 [2] = 6;
        
        aTest(d1);
        aTest(2.0, 3.0, 4.0);
        
        Employee [] staff2 = new Employee[3];
        staff2[0] = new Employee("Amy Zou", 75000, 1987, 12, 15);
        staff2[1] = new Employee("Kevin Chou", 50000, 1989, 10, 1);
        staff2[2] = new Employee("Tony Chen", 40000, 1990, 3, 1);
        for (Employee e : staff2){
            System.out.printf("Name: %-10s, Salary: %.2f, ID: %-4d, Data: %s\n", e.getName(), e.getSalary(), e.getId(), e.getHireDay().toString());
//            System.out.printf("Name: %11s, Salary: %.2f\n", e.getName(), e.getSalary());
        }
        
        Arrays.sort(staff2);
        for (Employee e : staff2){
            System.out.printf("Name: %-10s, Salary: %.2f, ID: %-4d, Data: %s\n", e.getName(), e.getSalary(), e.getId(), e.getHireDay().toString());
//            System.out.printf("Name: %11s, Salary: %.2f\n", e.getName(), e.getSalary());
        }
        
    }
    
}

